<template>
  <div>
    <el-dialog
      :visible.sync="batchEditViaible"
      :before-close="handleCloseBatchEdit"
      :append-to-body="true"
      class="small-common-dialog-size">
      <Title :title="batchType?'批量编辑选项':'批量添加问题'" style="margin-bottom: 10px;" />
      <div class="tip">{{ batchType ? '提示：每行为一个选项，换行添加新选项' : '提示：每行为一个问题，换行添加新问题' }}</div>
      <div>
        <el-input v-model="batchContent" placeholder="请输入内容" rows="6" type="textarea" resize="none" size="small" />
      </div>
      <div class="flex-center btn-box">
        <el-button type="primary" size="small" @click="handleSaveBatchEdit">确定</el-button>
        <el-button type="info" size="small" class="cancel-btn-style" @click="handleCloseBatchEdit">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Title from '@/components/Title';

export default {
  components: { Title },
  data() {
    return {
      batchEditViaible: false,
      batchContent: '',
      batchType: 0
    };
  },
  methods: {
    initData(data, type) {
      this.batchContent = data;
      this.batchType = type;
      this.batchEditViaible = true;
    },
    handleSaveBatchEdit() {
      if (!this.batchContent) {
        this.handleCloseBatchEdit();
        return;
      }
      this.$emit('handleSaveBatchEdit', this.batchContent);
      this.handleCloseBatchEdit();
    },
    handleCloseBatchEdit() {
      // this.batchContent = '';
      this.batchEditViaible = false;
    }
  }
};
</script>

<style scoped lang="scss">
.btn-box {
  margin-top: 16px;
  justify-content: center;
}
.tip {
  color: #999;
}
</style>
